import api from "./index"

// 获取文章列表
export const getArticleList = (params: PageParams): Promise<ResponseData<PageList<Article>>> =>
  api.post('/article/getAll', params);

// 根据id获取文章详情
export const getArticleById = (id: string): Promise<ResponseData<Article>> =>
  api.get(`/article/getDetail/${id}`);

// 根据分类获取文章列表
export const getArticleListByCategory = (params: ArticleCategory): Promise<ResponseData<PageList<Article>>> =>
  api.post('/article/getByCategory', params);

// 新增文章
export const addArticle = (params: Omit<Article, 'id' | 'created_time'>): Promise<ResponseData<Article>> =>
  api.post('/article/create', params);

// 编辑文章
export const editArticle = (params: Omit<Article, 'created_time'>): Promise<ResponseData<Article>> =>
  api.post('/article/update', params);

// 删除文章
export const deleteArticle = (id: string): Promise<ResponseData<null>> =>
  api.get(`/article/delete/${id}`);
